cmake_minimum_required(VERSION 3.10)

# 设置项目名称和版本
project(xzj_hdu_programing_learning VERSION 1.0)

# 指定C标准
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)

# 设置输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")

# GCC/Clang 选项
add_compile_options(
    # -Wno-unused-parameter   # 禁用未使用参数警告
    -Wall                   # 基本警告
    -Wextra                 # 额外警告
    -Wpedantic              # 严格模式
)

# 查找Python解释器
find_package(Python3 COMPONENTS Interpreter REQUIRED)

# 定义要运行的Python脚本路径
set(PYTHON_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/rename.py")

# 检查脚本文件是否存在
if(NOT EXISTS ${PYTHON_SCRIPT})
    message(FATAL_ERROR "Python脚本不存在: ${PYTHON_SCRIPT}")
endif()

# 创建自定义命令来运行Python脚本
add_custom_command(
    OUTPUT script_run_indicator  # 虚拟输出文件，用于跟踪是否已运行
    COMMAND Python3::Interpreter ${PYTHON_SCRIPT}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "running rename script"
)

# 创建自定义目标，以便可以通过make命令调用
add_custom_target(
    run_rename_script
    DEPENDS script_run_indicator
    COMMENT "run rename script ... ok"
)

# 添加可执行文件
add_executable(hello hello.c)
add_executable(gta-c-question "gta/c/test.c")